part of _;

extension on MainPage_Home_Suggest {
  Widget view_search() {
    return StatefulBuilder(
      builder: (context, setState) {
        return GestureDetector(
          onTap: () => yIntent(SearchPage(), intentType: YIntentType.Present),
          child: Container(
            margin: EdgeInsets.fromLTRB(5, 5, 5, 5),
            padding: EdgeInsets.all(2),
            decoration: BoxDecoration(borderRadius: BorderRadius.circular(99), border: Border.all(color: YConfig.themeColor, width: 1.5), color: Colors.white),
            child: Row(
              children: [
                yIsWeb
                    ? YEmpty()
                    : YButton(
                        onTap: () => yIntent(ScanQRCodePage((result) => AppUtils.switchScheme(yPage, result)), intentType: YIntentType.Present),
                        width: 30,
                        height: 30,
                        margin: EdgeInsets.only(left: 10, right: 10),
                        child: Image.asset("images/icon_scan.png", width: 25),
                      ),
                Container(width: yIsWeb ? 0 : 1, height: 25, color: Colors.grey.shade300, margin: EdgeInsets.only(right: 10)),
                Expanded(child: Text("请输入搜索内容...", style: TextStyle(color: Colors.grey))),
                YButton(
                  width: 30,
                  height: 30,
                  margin: EdgeInsets.only(right: 2),
                  child: Icon(IFinal.Others.isProductShowGrid ? Icons.grid_view : Icons.format_list_bulleted, color: YConfig.themeColor),
                  onTap: () => AppUtils.toggleProductShowType(yPage, setState: setState),
                ),
                Container(
                  padding: EdgeInsets.fromLTRB(20, 7, 20, 7),
                  decoration: BoxDecoration(color: YConfig.themeColor, borderRadius: BorderRadius.circular(99)),
                  child: Text("搜索", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 14)),
                ),
              ],
            ),
          ),
        );
      },
    );
  }

  Widget view_banner_big() {
    return model!.banners_big.isEmpty
        ? YEmpty()
        : Container(
            height: yScreenSize().width / 5 * 2,
            margin: EdgeInsets.only(bottom: 5),
            child: Swiper(
              pagination: SwiperPagination(),
              autoplay: true,
              viewportFraction: 0.9,
              scale: 0.95,
              itemCount: model!.banners_big.length,
              itemBuilder: (context, index) => YImageCorner(null, null, model!.banners_big[index].img, 10),
              onTap: (index) => AppUtils.goIntent(yPage, model!.banners_big[index].type, params: {
                "id": model!.banners_big[index].id,
                "content": model!.banners_big[index].title,
              }),
            ),
          );
  }

  Widget view_func(bool overlapsContent) {
    const column = 5, space = 5.0;
    var imgSize = (yScreenSize().width - (4 + column - 1) * space) / column - space * 4;
    return model!.funcs.isEmpty
        ? YEmpty()
        : Container(
            color: overlapsContent ? Colors.white : Colors.transparent,
            child: Card(
              elevation: overlapsContent ? 0 : 1,
              margin: EdgeInsets.fromLTRB(10, 0, 10, 0),
              color: Colors.white,
              child: Container(
                height: (yScreenSize().width - 20 - (column - 1) * space) / 5 / 0.85,
                child: GridView.builder(
                  primary: false,
                  shrinkWrap: true,
                  padding: EdgeInsets.zero,
                  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: column, mainAxisSpacing: 0, crossAxisSpacing: space, childAspectRatio: 0.85),
                  itemCount: model!.funcs.length,
                  itemBuilder: (context, index) {
                    var func = model!.funcs[index];
                    return YButton(
                      onTap: () => AppUtils.goIntent(yPage, func.type, params: {
                        "id": func.id,
                        "content": func.title,
                      }),
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          YImage(imgSize, imgSize, func.img, fit: BoxFit.cover),
                          YSpacer(height: 3),
                          Text(func.title, style: TextStyle(fontSize: 13, color: Colors.grey.shade700)),
                        ],
                      ),
                    );
                  },
                ),
              ),
            ),
          );
  }

  Widget view_banner_small() {
    var width = (yScreenSize().width - 30) / 2;
    var height = width * 1.0;
    Widget view_item(List<ShouYeTJModel_Banner> models) {
      return Expanded(
        child: Card(
          elevation: 1,
          color: Colors.white,
          margin: EdgeInsets.zero,
          child: ClipRRect(
            borderRadius: BorderRadius.circular(5),
            child: Container(
              width: width,
              height: height,
              child: Swiper(
                pagination: SwiperPagination(),
                duration: 1000,
                autoplay: true,
                itemCount: models.length,
                itemBuilder: (context, index) => YImage(null, null, models[index].img, fit: BoxFit.cover),
                onTap: (index) => AppUtils.goIntent(yPage, models[index].type, params: {
                  "id": models[index].id,
                  "content": models[index].title,
                }),
              ),
            ),
          ),
        ),
      );
    }

    return model!.banners_small_left.isEmpty || model!.banners_small_right.isEmpty
        ? YEmpty()
        : Container(
            margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
            child: Row(
              children: [
                view_item(model!.banners_small_left),
                YSpacer(width: 10),
                view_item(model!.banners_small_right),
              ],
            ),
          );
  }
}
